package com.app.common.dataDictionary.PO;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;

import com.app.common.dataDictionary.DE.DE_APPVERSION_NUMBER;
import com.app.common.dataDictionary.DE.DE_PHONETYPE;
import com.app.common.dataDictionary.DE.DE_USERFEEDBACK_ID;
import com.app.common.dataDictionary.DE.DE_USERFEEDBACK_NR;
import com.app.common.dataDictionary.DE.DE_USERFEEDBACK_OPPTIME;
import com.css.sword.kernel.base.annotation.PersistObject;
import com.css.sword.kernel.base.dataElement.AbsPersistObject;
import com.css.sword.kernel.base.dataElement.BaseDataElement;
import com.css.sword.kernel.base.dataElement.DateDE;
import com.css.sword.kernel.base.exception.SwordBaseCheckedException;


/**
 * 用户意见反馈表; InnoDB free: 11264 kB
 */
@PersistObject
public class TUserfeedbackPO extends AbsPersistObject {
	//private static final long serialVersionUID = 443322639867531273L;
	private static final long serialVersionUID = 1L;
	private static final BitSet HAS_DEFAULT_VALUE = new BitSet(5);
	
	static{
	}
	
	/**
	 * 物理表名
	 */
	public static final String TABLE_NAME = "t_userfeedback";

	/**
	 * 主键id
	 */
	private DE_USERFEEDBACK_ID userfeedbackId = DE_USERFEEDBACK_ID.getTemplateInstance();

	/**
	 * 手机类型
	 */
	private DE_PHONETYPE phonetype = DE_PHONETYPE.getTemplateInstance();

	/**
	 * 对应的手机类型应用版本号
	 */
	private DE_APPVERSION_NUMBER appversionNumber = DE_APPVERSION_NUMBER.getTemplateInstance();

	/**
	 * 用户意见反馈操作时间
	 */
	private DE_USERFEEDBACK_OPPTIME userfeedbackOpptime = DE_USERFEEDBACK_OPPTIME.getTemplateInstance();

	/**
	 * 用户意见反馈内容
	 */
	private DE_USERFEEDBACK_NR userfeedbackNr = DE_USERFEEDBACK_NR.getTemplateInstance();


	public TUserfeedbackPO(){
		this.insertState = new BitSet(5);
		this.updateState = new BitSet(5);
	}

	
	/**
	 * 获取 "主键id" 值
	 */	
	public DE_USERFEEDBACK_ID getUserfeedbackId(){
		return  userfeedbackId;
	}
	
	/**
	 * 设置 "主键id" 值
	 */
	public void setUserfeedbackId(DE_USERFEEDBACK_ID userfeedbackId) {
		if(userfeedbackId == null){
			userfeedbackId= DE_USERFEEDBACK_ID.getTemplateInstance();
		}
		recordChangeFlag(0);
		this.userfeedbackId = userfeedbackId;
	}
	
	/**
	 * 获取 "手机类型" 值
	 */	
	public DE_PHONETYPE getPhonetype(){
		return  phonetype;
	}
	
	/**
	 * 设置 "手机类型" 值
	 */
	public void setPhonetype(DE_PHONETYPE phonetype) {
		if(phonetype == null){
			phonetype= DE_PHONETYPE.getTemplateInstance();
		}
		recordChangeFlag(1);
		this.phonetype = phonetype;
	}
	
	/**
	 * 获取 "对应的手机类型应用版本号" 值
	 */	
	public DE_APPVERSION_NUMBER getAppversionNumber(){
		return  appversionNumber;
	}
	
	/**
	 * 设置 "对应的手机类型应用版本号" 值
	 */
	public void setAppversionNumber(DE_APPVERSION_NUMBER appversionNumber) {
		if(appversionNumber == null){
			appversionNumber= DE_APPVERSION_NUMBER.getTemplateInstance();
		}
		recordChangeFlag(2);
		this.appversionNumber = appversionNumber;
	}
	
	/**
	 * 获取 "用户意见反馈操作时间" 值
	 */	
	public DE_USERFEEDBACK_OPPTIME getUserfeedbackOpptime(){
		return  userfeedbackOpptime;
	}
	
	/**
	 * 设置 "用户意见反馈操作时间" 值
	 */
	public void setUserfeedbackOpptime(DE_USERFEEDBACK_OPPTIME userfeedbackOpptime) {
		if(userfeedbackOpptime == null){
			userfeedbackOpptime= DE_USERFEEDBACK_OPPTIME.getTemplateInstance();
		}
		recordChangeFlag(3);
		this.userfeedbackOpptime = userfeedbackOpptime;
	}
	
	/**
	 * 获取 "用户意见反馈内容" 值
	 */	
	public DE_USERFEEDBACK_NR getUserfeedbackNr(){
		return  userfeedbackNr;
	}
	
	/**
	 * 设置 "用户意见反馈内容" 值
	 */
	public void setUserfeedbackNr(DE_USERFEEDBACK_NR userfeedbackNr) {
		if(userfeedbackNr == null){
			userfeedbackNr= DE_USERFEEDBACK_NR.getTemplateInstance();
		}
		recordChangeFlag(4);
		this.userfeedbackNr = userfeedbackNr;
	}


	@Override
	public BaseDataElement<?>[] fields(){
		return new BaseDataElement<?>[] {userfeedbackId,phonetype,appversionNumber,userfeedbackOpptime,userfeedbackNr};
	}
	
	@Override
	public String[] fieldNames() {
		return new String[]{"userfeedbackId","phonetype","appversionNumber","userfeedbackOpptime","userfeedbackNr"};
	}
	
	@Override
	public BaseDataElement<?> getFieldValue(String fieldName)  {
		if ("userfeedbackId".equals(fieldName)) {
			return userfeedbackId;
		}
		if ("phonetype".equals(fieldName)) {
			return phonetype;
		}
		if ("appversionNumber".equals(fieldName)) {
			return appversionNumber;
		}
		if ("userfeedbackOpptime".equals(fieldName)) {
			return userfeedbackOpptime;
		}
		if ("userfeedbackNr".equals(fieldName)) {
			return userfeedbackNr;
		}
 
		throw new IllegalArgumentException("PO对象中没有"+fieldName+"字段");
	}
	
	@Override
	public TUserfeedbackPO setFieldValue(String fieldName, Object fieldValue) throws SwordBaseCheckedException {
		if (fieldValue != null && !(fieldValue instanceof BaseDataElement<?>)) {
			throw new SwordBaseCheckedException("字段值类型不是DataElelement子类型");
		}

		if ("userfeedbackId".equals(fieldName)) {
			if (fieldValue == null) {
				setUserfeedbackId(null);
			} else {
				setUserfeedbackId((DE_USERFEEDBACK_ID) fieldValue);
			}
			return this;
		}

		if ("phonetype".equals(fieldName)) {
			if (fieldValue == null) {
				setPhonetype(null);
			} else {
				setPhonetype((DE_PHONETYPE) fieldValue);
			}
			return this;
		}

		if ("appversionNumber".equals(fieldName)) {
			if (fieldValue == null) {
				setAppversionNumber(null);
			} else {
				setAppversionNumber((DE_APPVERSION_NUMBER) fieldValue);
			}
			return this;
		}

		if ("userfeedbackOpptime".equals(fieldName)) {
			if (fieldValue == null) {
				setUserfeedbackOpptime(null);
			} else {
				setUserfeedbackOpptime((DE_USERFEEDBACK_OPPTIME) fieldValue);
			}
			return this;
		}

		if ("userfeedbackNr".equals(fieldName)) {
			if (fieldValue == null) {
				setUserfeedbackNr(null);
			} else {
				setUserfeedbackNr((DE_USERFEEDBACK_NR) fieldValue);
			}
			return this;
		}

		throw new SwordBaseCheckedException("PO对象中没有"+fieldName+"字段");
	}

	@Override
	protected TUserfeedbackPO clone() {
		TUserfeedbackPO t = new TUserfeedbackPO();
		
		t.setUserfeedbackId(this.userfeedbackId);
		t.setPhonetype(this.phonetype);
		t.setAppversionNumber(this.appversionNumber);
		t.setUserfeedbackOpptime(this.userfeedbackOpptime);
		t.setUserfeedbackNr(this.userfeedbackNr);

		return t;
	}

	@Override
	public TUserfeedbackPO loadMap(Map<String, Object> dataMap) throws SwordBaseCheckedException {
		Object value = null;

		if(dataMap.containsKey("userfeedbackId")){
			value = dataMap.get("userfeedbackId");
			
			if (value == null) {
				this.setUserfeedbackId(null);
			} else {
				if (value instanceof DE_USERFEEDBACK_ID) {
					this.setUserfeedbackId((DE_USERFEEDBACK_ID) value);
				}
			    else {
					this.setUserfeedbackId(new DE_USERFEEDBACK_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("phonetype")){
			value = dataMap.get("phonetype");
			
			if (value == null) {
				this.setPhonetype(null);
			} else {
				if (value instanceof DE_PHONETYPE) {
					this.setPhonetype((DE_PHONETYPE) value);
				}
			    else {
					this.setPhonetype(new DE_PHONETYPE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("appversionNumber")){
			value = dataMap.get("appversionNumber");
			
			if (value == null) {
				this.setAppversionNumber(null);
			} else {
				if (value instanceof DE_APPVERSION_NUMBER) {
					this.setAppversionNumber((DE_APPVERSION_NUMBER) value);
				}
			    else {
					this.setAppversionNumber(new DE_APPVERSION_NUMBER(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userfeedbackOpptime")){
			value = dataMap.get("userfeedbackOpptime");
			
			if (value == null) {
				this.setUserfeedbackOpptime(null);
			} else {
				if (value instanceof DE_USERFEEDBACK_OPPTIME) {
					this.setUserfeedbackOpptime((DE_USERFEEDBACK_OPPTIME) value);
				}
				else if(value instanceof java.util.Date){
					this.setUserfeedbackOpptime(new DE_USERFEEDBACK_OPPTIME((java.util.Date)value));
				}
			    else {
					this.setUserfeedbackOpptime(new DE_USERFEEDBACK_OPPTIME(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userfeedbackNr")){
			value = dataMap.get("userfeedbackNr");
			
			if (value == null) {
				this.setUserfeedbackNr(null);
			} else {
				if (value instanceof DE_USERFEEDBACK_NR) {
					this.setUserfeedbackNr((DE_USERFEEDBACK_NR) value);
				}
			    else {
					this.setUserfeedbackNr(new DE_USERFEEDBACK_NR(value.toString()));
				}
			}
		}

		return this;
	}
	
	@Override
	public Map<String,Object> toMap() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("userfeedbackId", userfeedbackId);
		dataMap.put("phonetype", phonetype);
		dataMap.put("appversionNumber", appversionNumber);
		dataMap.put("userfeedbackOpptime", userfeedbackOpptime);
		dataMap.put("userfeedbackNr", userfeedbackNr);
		
		return dataMap;
	}
	
	@Override
	public Map<String,Object> toMapWithDEValue() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("userfeedbackId", (userfeedbackId==null?null:userfeedbackId.value));
		dataMap.put("phonetype", (phonetype==null?null:phonetype.value));
		dataMap.put("appversionNumber", (appversionNumber==null?null:appversionNumber.value));
		dataMap.put("userfeedbackOpptime", (userfeedbackOpptime==null?null:userfeedbackOpptime.value));
		dataMap.put("userfeedbackNr", (userfeedbackNr==null?null:userfeedbackNr.value));
		
		return dataMap;
	}
	
	@Override
	public TUserfeedbackPO newInstance() {
		return new TUserfeedbackPO();
	}
	
	@Override
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@Override
	public BaseDataElement<?>[] getPrimaryKey() {
		return new BaseDataElement<?>[]{userfeedbackId};
	}

	@Override
	public void checkNotNull(byte sqlType) throws SwordBaseCheckedException {
		StringBuilder errorMsg = new StringBuilder();
		// insert
		if (sqlType == 0) {
				//只校验不可为空但又没有默认值的字段
				if (userfeedbackId.value == null && !HAS_DEFAULT_VALUE.get(0)) {
					errorMsg.append("字段userfeedbackId不允许为空\n");
				}
				if (phonetype.value == null && !HAS_DEFAULT_VALUE.get(1)) {
					errorMsg.append("字段phonetype不允许为空\n");
				}
				if (appversionNumber.value == null && !HAS_DEFAULT_VALUE.get(2)) {
					errorMsg.append("字段appversionNumber不允许为空\n");
				}
				if (userfeedbackNr.value == null && !HAS_DEFAULT_VALUE.get(4)) {
					errorMsg.append("字段userfeedbackNr不允许为空\n");
				}

		}
		// update
		else if (sqlType == 1) {
		if (updateState.get(0) && userfeedbackId.value == null) {
			errorMsg.append("字段userfeedbackId不允许为空\n");
		}
		if (updateState.get(1) && phonetype.value == null) {
			errorMsg.append("字段phonetype不允许为空\n");
		}
		if (updateState.get(2) && appversionNumber.value == null) {
			errorMsg.append("字段appversionNumber不允许为空\n");
		}
		if (updateState.get(4) && userfeedbackNr.value == null) {
			errorMsg.append("字段userfeedbackNr不允许为空\n");
		}

		}
		
		if (errorMsg.length() > 0) {
			errorMsg.setLength(errorMsg.length() - 1);
			throw new SwordBaseCheckedException(errorMsg.toString());
		}
	}

	@Override
	public void updateLrrq(DateDE lrrq) {
	}

	@Override
	public void updateXgrq(DateDE xgrq) {
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("userfeedbackId:").append(userfeedbackId.value!=null?userfeedbackId:"").append(" ").append("phonetype:").append(phonetype.value!=null?phonetype:"").append(" ").append("appversionNumber:").append(appversionNumber.value!=null?appversionNumber:"").append(" ").append("userfeedbackOpptime:").append(userfeedbackOpptime.value!=null?userfeedbackOpptime:"").append(" ").append("userfeedbackNr:").append(userfeedbackNr.value!=null?userfeedbackNr:"").append(" ");
		return str.toString();
	}
	
}
